var ns, app;
app = new Vue({
    el: '#app',
    data: {
        dateArray: [],
    },
    methods: {
        get_data: function() {
            api.toast({
                msg: '刷新成功',
                duration: 2000,
                location: 'bottom'
            });
        },
        no_open: function() {
            api.alert({
                title: '提示',
                msg: '功能暂时未开放,敬请期待',
            }, function(ret, err) {});
        },
        openTask: function() {
            api.closeWin();
        },
        openWin: function(item, params) {
            var that = this;
            if (item.url == '') {
                return;
            }
            params = params || {
                status: -1
            };
            ns.openWin(item.url, item.name, params);
        },
        setDates: function() {

        },
        openDate: function() {
            var that = this;
            UICalendar.open({
                rect: {
                    x: 30,
                    y: 80,
                    w: api.frameWidth - 60,
                    h: 340
                },
                styles: {
                    bg: 'rgba(0,0,0,0)',
                    week: {
                        weekdayColor: '#3b3b3b',
                        weekendColor: '#a8d400',
                        size: 12
                    },
                    date: {
                        color: '#3b3b3b',
                        selectedColor: '#fff',
                        selectedBg: '#a8d500',
                        size: 12
                    },
                    today: {
                        color: 'rgb(230,46,37)',
                        bg: '#06AF8F'
                    },
                    specialDate: {
                        color: '#a8d500',
                        bg: 'widget://image/a.png'
                    },
                },
                switchMode: 'horizontal',
                fixedOn: api.frameName,
                fixed: false
            }, function(ret, err) {
                if (ret) {
                    that.dateArray = ret;
                    var str = that.dateArray.year + '-' + that.dateArray.month + '-' + that.dateArray.day;
                    api.confirm({
                        title: '添加事件',
                        msg: '是否向' + str + '添加事件',
                        buttons: ['确定', '取消']
                    }, function(ret, err) {
                        var index = ret.buttonIndex;
                        if (index == 1) {
                        } else {
                        }
                    });
                } else {
                }
            });
        },
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    UICalendar = api.require('UICalendar');
    UICalendar.turnPage({
        date: '2015-02'
    });
    app.openDate();
};
